import api from "@/util/api";
async function findAll(pageNo = 1, pageSize = 10, params = {}) {
    let resp = await api({
        url: "/order-api/api/v1/order",
        method: "get",
        params: {
            pageNo,
            pageSize,
            ...params
        }
    });
    return resp.data;
}

async function deleteById(id) {
    let resp = await api({
        url:"/order-api/api/v1/order/deleteById/"+id,
        method: "delete",
        params: {
            id
        }
    });
    return resp;
}

async function save(order){

    let resp = await api({
        url: "/order",
        method: "post",
        data: order
    });
    return resp;
}

async function update(order){
    let resp = await api({
        url: "/order",
        method: "put",
        data: order
    });
    return resp;
}

async function deleteAll(ids){
    let resp = await api({
        url:"/order/deleteIds",
        method:"delete",
        data:ids
    });
    return resp;
}

async function cancelOrder(id){
    let resp = await api({
        url: "/order/cancelOrder",
        method: "put",
        params: {
            id
        }
    });
    return resp;
}

async function startOrder(id){
    let resp = await api({
        url: "/order-api/api/v1/order/fahuo/"+id,
        method: "put",
        params: {
            id
        }
    });
    return resp;
}

// 修改findById函数，订单的id
async function findById(id) {
    let resp = await api({
        url: "/order-api/api/v1/order/findById/" + id,
        method: "get"
    });
    return resp;
}

async function songOrder(id){
    let resp = await api({
        url: "/order-api/api/v1/order/songda/"+id,
        method: "put",
        params: {
            id
        }
    });
    return resp;
}
export {findAll, deleteById,deleteAll, save, update,cancelOrder,startOrder,findById,songOrder};